/*
  Copyright (C) 2011, Kyungjoo Kim
  
  This file is part of UHM (Unassembled HyperMatrix) sparse direct solver.
  
  All rights reserved.

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.
  
  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.
  
  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free Software
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  Also add information on how to contact you by electronic and paper mail.
  
  
  Kyungjoo Kim
  iamkyungjoo@gmail.com
*/
#ifndef UHM_WRAPPER_FORT_LINAL_HXX_
#define UHM_WRAPPER_FORT_LINAL_HXX_

extern "C" {
  // ** Query
  extern F_void UHM_C2F(uhm_solver_petsc_interfaced)(F_ptr *solver, F_int *flag);

  // ** Solvers
  extern F_void UHM_C2F(uhm_direct_lu_nopiv_initialize)(F_int *type, F_int *rhs, F_int *blk,
                                                        F_ptr *solver);
  extern F_void UHM_C2F(uhm_direct_lu_piv_initialize)(F_int *type, F_int *rhs, F_int *blk,
                                                      F_ptr *solver);
  extern F_void UHM_C2F(uhm_direct_lu_incpiv_initialize)(F_int *type, F_int *rhs, F_int *blk,
                                                         F_ptr *solver);

  // Direct Methods
  extern F_void UHM_C2F(uhm_direct_solver_decompose)(F_ptr *solver);
  extern F_void UHM_C2F(uhm_direct_solver_updecompose)(F_ptr *solver);
  
  extern F_void UHM_C2F(uhm_direct_solver_solve)(F_ptr *solver);
  extern F_void UHM_C2F(uhm_direct_solver_check)(F_ptr *solver, F_double *residual);


  extern F_void UHM_C2F(uhm_solver_finalize)(F_ptr *solver);
  extern F_void UHM_C2F(uhm_solver_content)(F_ptr *solver);
  extern F_void UHM_C2F(uhm_solver_report)(F_ptr *solver);
  extern F_void UHM_C2F(uhm_solver_create)(F_ptr *solver);
  extern F_void UHM_C2F(uhm_solver_copy_in_begin)(F_ptr *solver);
  extern F_void UHM_C2F(uhm_solver_copy_in_end)(F_ptr *solver);
  extern F_void UHM_C2F(uhm_solver_copy_in_ab)(F_ptr *solver,
                                               F_int *el, F_int *eids,
                                               F_int *nodes, F_int *nids,
                                               F_int *dofs, F_int *weights, F_int *kinds, F_int *n_nodes,
                                               F_int *cs,  F_void *buf_A,  F_void *buf_B);
  extern F_void UHM_C2F(uhm_solver_copy_in_b)(F_ptr *solver,
                                              F_int *nodes, F_int *ids,
                                              F_int *dofs, F_int *n_nodes,
                                              F_int *cs,  F_void *buf_B);
  extern F_void UHM_C2F(uhm_solver_copy_out_el)(F_ptr *solver,
                                                F_int *el, F_int *ids,
                                                F_int *cs,  F_void *X);
  extern F_void UHM_C2F(uhm_solver_copy_out_nodes)(F_ptr *solver,
                                                   F_int *nodes, F_int *ids, F_int *n_nodes,
                                                   F_int *cs,  F_void *X);
  extern F_void UHM_C2F(uhm_solver_set_caching)(F_ptr *solver, F_int *caching);
  extern F_void UHM_C2F(uhm_solver_get_caching)(F_ptr *solver, F_int *caching);
  extern F_void UHM_C2F(uhm_solver_set_level)(F_ptr *solver, F_int  *level);
  extern F_void UHM_C2F(uhm_solver_get_level)(F_ptr *solver, F_int  *level);
  extern F_void UHM_C2F(uhm_solver_get_rhs)(F_ptr *solver, F_int *rhs);

  extern F_void UHM_C2F(uhm_solver_clear)(F_ptr *solver);
  extern F_void UHM_C2F(uhm_solver_flush)(F_ptr *solver);
}


#endif
